package com.Test;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;

public class Test29 {
    public static void main(String[] args) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

        LocalDate today = LocalDate.now();

        // 获取当前周的第一天
        LocalDate startOfWeek = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));

        // 获取当前周的最后一天
        LocalDate endOfWeek = today.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));

        // 转换为字符串
        String startOfWeekStr = startOfWeek.format(formatter);
        String endOfWeekStr = endOfWeek.format(formatter);

        System.out.println("Start of Week: " + startOfWeekStr);
        System.out.println("End of Week: " + endOfWeekStr);
    }
}
